package com.jn.erp.wechat.student.api.controller;

import com.jn.erp.common.core.page.TableDataInfo;
import com.jn.erp.common.core.result.AjaxResult;
import com.jn.erp.security.utils.SecurityUtils;
import com.jn.erp.web.api.course.entity.dto.TCourseOrderDto;
import com.jn.erp.web.api.course.entity.vo.TCourseOrderVo;
import com.jn.erp.web.api.course.service.TCourseOrderService;
import com.jn.erp.web.api.student.entity.dto.TStudentCourseDto;
import com.jn.erp.web.api.student.entity.vo.TStudentCourseVo;
import com.jn.erp.web.api.student.service.StudentCourseService;
import com.jn.erp.wechat.common.api.controller.base.BaseWxAuthController;
import com.jn.erp.wechat.common.api.entity.dto.WxUserDto;
import com.jn.erp.wechat.core.WxTableDataInfo;
import com.jn.erp.wechat.student.api.entity.vo.StudentCourseInfoVo;
import com.jn.erp.wechat.student.api.service.ClassInfoService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <pre>
 *
 * </pre>
 *
 * @author sunjiyong
 * @since 2024/11/5 13:37
 */
@AllArgsConstructor
@RestController
@RequestMapping("/wxs/course")
public class WxsStudentCourseController extends BaseWxAuthController {

    @Autowired
    private ClassInfoService classInfoService;

    @Autowired
    private StudentCourseService studentCourseService;
//
//    @Autowired
//    private TCourseOrderService tCourseOrderService;

    /**
     * 学员内报读课程
     */
    @PostMapping("/listSecond")
    public AjaxResult listSecond(@RequestBody StudentCourseInfoVo studentCourseInfoVo) {
        //获取登录家长端相关信息
        WxUserDto studentUser = getStudentUser();
        studentCourseInfoVo.setUserId(studentUser.getUserId());
        List<StudentCourseInfoVo> list = classInfoService.listSecond(studentCourseInfoVo);
        return AjaxResult.success(list);
    }


    /**
     * 订单详情
     */
    @PostMapping("/detail")
    public AjaxResult detail(@RequestBody TStudentCourseVo tStudentCourseVo) {
        //获取登录家长端相关信息
        WxUserDto studentUser = getStudentUser();
        TStudentCourseDto tStudentCourseDto = classInfoService.studentOrderDetail(tStudentCourseVo);
        return AjaxResult.success(tStudentCourseDto);
    }


    /**
     * 课消列表
     * */
    @GetMapping("/orderListThird")
    public WxTableDataInfo orderListThird(TCourseOrderVo tCourseOrderVo) {
        //获取登录家长端相关信息
        WxUserDto studentUser = getStudentUser();
        startPage();
        List<TCourseOrderDto> tCourseOrderDtos= classInfoService.orderListThird(tCourseOrderVo);
        return getWxDataTable(tCourseOrderDtos);
    }

}
